package tamavo.models
{
	import mx.collections.ArrayCollection;
	import mx.utils.ArrayUtil;
	
	import tamavo.vo.PlanVO;
	import tamavo.vo.ProcessVO;
	
	[Bindable]
	public class ModelLocator
	{
		[Inject(id="plansData")]
		public var plans :ArrayCollection;
		
		[Inject(id="processesData")]
		public var processes :ArrayCollection;
		
		public var selectedPlan :PlanVO;
		
		public function ModelLocator()
		{
		}
		
		[PostConstruct]
		public function init():void
		{
			processes.filterFunction = filterfunction;
			processes.refresh();
		}
		
		protected function filterfunction( procces:ProcessVO ):Boolean
		{
			if(!selectedPlan)
				return false;
			var ac:ArrayCollection = new ArrayCollection(selectedPlan.processes);
			if(ac.contains(procces.idProcess))
				return true;
				
			return false;
		}
	}
}